<?php
	/**
	* Companies manager
	* @author trungdt
	* @since Apr, 2012
	*/

	if (!defined('EXPONENT')) exit('');
	exponent_flow_set(SYS_FLOW_PROTECTED);
	require_once(BASE."modules/formhelpermodule/formhelper.php");
	
	$formhelper=new formhelper("surveymodule","_company_manager_title","_",$loc);
	$formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
	$formhelper->setGridOptions("height",500);
	$formhelper->setGridOptions("idField","id");
	$formhelper->setGridOptions("pagination",true);
	$formhelper->setGridOptions("pageNumber","1");
	$formhelper->setGridOptions("pageSize","20");
	$formhelper->setGridOptions("rownumbers",true);
	$formhelper->setGridOptions("singleSelect",true);
	$formhelper->setGridOptions("autoRowHeight",true);
	$formhelper->setGridID("survey_cat_manage");
	//$formhelper->setInitCallback("TestGridCallback");
	
	$js=URL_FULL."modules/surveymodule/js/CompanyManager.js";
	$formhelper->addJS($js);
	$js=URL_FULL."js/jqueryEasyUI/dataGrid_detailview.js";
	$formhelper->addJS($js);
	
	$formhelper->setColumnType(1);
	$formhelper->addColumn(array("field"=>"id","title"=>"ID",'width'=>40, "sortable"=>true));
	$formhelper->addColumn(array("field"=>"name","title"=>"Name",'width'=>130, "sortable"=>true));
	$formhelper->addColumn(array("field"=>"seo_name","title"=>"Seo name",'width'=>130));
	$formhelper->addColumn(array("field"=>"is_active","title"=>"Active",'width'=>70, "formatter"=>"function(___grid_formatter_is_active", "sortable"=>true));
	$formhelper->addColumn(array("field"=>"description","title"=>"Description",'width'=>190));
	
	$link_param = "/index.php?module=surveymodule&action=company_getjson&ajax_action=1&src={$loc->src}";
	$formhelper->setURLDataStream($link_param); 
	
	$formhelper->setPreInitJSCall("preLoadJS");
	$formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad");
	$formhelper->setGridOptions("onSelect","function(____grid_OnSelect");
	$formhelper->setGridOptions("onUnselect","function(____grid_OnUnSelect");
	$formhelper->setGridOptions("detailFormatter","function(____grid_event_detailFormatter");
	$formhelper->setGridOptions("onExpandRow","function(____grid_event_onExpandRow");
	// sorry for fake call :)) We just want to get detailview instead of "detailview"
	$formhelper->setGridOptions("view","function(___detailview");
	
	$toolbar_template=new template("surveymodule","_Company_Manager_ToolbarHTML",$loc);
	$toolbar_template->register_permissions(array('administrate',"manage"),$loc);
	$toolbar_html=$toolbar_template->render();
	$formhelper->addToolbarHTML($toolbar_html);
	$formhelper->addToolbarStyle("height: 50px;");
	$formhelper->register_permissions(array('administrate',"manage"),$loc);
	$html = $formhelper->output();
?>
